<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Function template add_file_log</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../utilities.html#header.boost.log.utility.setup.file_hpp" title="Header &lt;boost/log/utility/setup/file.hpp&gt;">
<link rel="prev" href="wadd_console_log.html" title="Function wadd_console_log">
<link rel="next" href="basic_filter_factory.html" title="Class template basic_filter_factory">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="wadd_console_log.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../utilities.html#header.boost.log.utility.setup.file_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="basic_filter_factory.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.add_file_log"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Function template add_file_log</span></h2>
<p>boost::log::add_file_log</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../utilities.html#header.boost.log.utility.setup.file_hpp" title="Header &lt;boost/log/utility/setup/file.hpp&gt;">boost/log/utility/setup/file.hpp</a>&gt;

</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span><span class="special">...</span> ArgsT<span class="special">&gt;</span> 
  <span class="identifier">shared_ptr</span><span class="special">&lt;</span> <span class="identifier">sinks</span><span class="special">::</span><span class="identifier">synchronous_sink</span><span class="special">&lt;</span> <span class="identifier">sinks</span><span class="special">::</span><span class="identifier">text_file_backend</span> <span class="special">&gt;</span> <span class="special">&gt;</span> 
  <span class="identifier">add_file_log</span><span class="special">(</span><span class="identifier">ArgsT</span><span class="special">...</span> <span class="keyword">const</span> <span class="special">&amp;</span> args<span class="special">)</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm46846445553632"></a><h2>Description</h2>
<p>The function initializes the logging library to write logs to a file stream.</p>
<p>

</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The <code class="computeroutput">target</code> named argument is required to enable the file collector and the limits associated with the target directory. If the parameter is not specified, the file collector will not be created and the limits will not be maintained. </p></td></tr>
</table></div>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">args</code></span></p></td>
<td>
<p>A number of named arguments. The following parameters are supported: </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p><code class="computeroutput">file_name</code> The active file name or its pattern. This parameter is mandatory. </p></li>
<li class="listitem"><p><code class="computeroutput">target_file_name</code> - Specifies the target file name pattern to use to rename the log file on rotation, before passing it to the file collector. The pattern may contain the same placeholders as the <code class="computeroutput">file_name</code> parameter. By default, no renaming is done, i.e. the written log file keeps its name according to <code class="computeroutput">file_name</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">open_mode</code> The mask that describes the open mode for the file. See <code class="computeroutput">std::ios_base::openmode</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">rotation_size</code> The size of the file at which rotation should occur. See <code class="computeroutput">basic_text_file_backend</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">time_based_rotation</code> The predicate for time-based file rotations. See <code class="computeroutput">basic_text_file_backend</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">auto_flush</code> A boolean flag that shows whether the sink should automatically flush the file after each written record. </p></li>
<li class="listitem"><p><code class="computeroutput">auto_newline_mode</code> - Specifies automatic trailing newline insertion mode. Must be a value of the <code class="computeroutput">auto_newline_mode</code> enum. By default, is <code class="computeroutput">auto_newline_mode::insert_if_missing</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">target</code> The target directory to store rotated files in. Enables file collector and, if specified, limits associated with the target directory. See <code class="computeroutput">sinks::file::make_collector</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">max_size</code> The maximum total size of rotated files in the target directory. See <code class="computeroutput">sinks::file::make_collector</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">min_free_space</code> Minimum free space in the target directory. See <code class="computeroutput">sinks::file::make_collector</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">max_files</code> The maximum total number of rotated files in the target directory. See <code class="computeroutput">sinks::file::make_collector</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">scan_method</code> The method of scanning the target directory for log files. See <code class="computeroutput">sinks::file::scan_method</code>. </p></li>
<li class="listitem"><p><code class="computeroutput">filter</code> Specifies a filter to install into the sink. May be a string that represents a filter, or a filter lambda expression. </p></li>
<li class="listitem"><p><code class="computeroutput">format</code> Specifies a formatter to install into the sink. May be a string that represents a formatter, or a formatter lambda expression (either streaming or Boost.Format-like notation).</p></li>
</ul></div>
<p>
</p>
</td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>Pointer to the constructed sink.</p></td>
</tr>
</tbody>
</table></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2007-2021 Andrey Semashev<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="wadd_console_log.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../utilities.html#header.boost.log.utility.setup.file_hpp"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="basic_filter_factory.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
